<?php
ini_set('display_errors', 0);
error_reporting(E_ERROR | E_WARNING | E_PARSE);

if ($_SERVER['QUERY_STRING'] == '')
    die('Wrong Entry Point !!!');

define('JPATH_BASE', dirname(__FILE__));
define('DS', DIRECTORY_SEPARATOR);
require_once(JPATH_BASE . DS . "include" . DS . "arrays.php");
require_once(JPATH_BASE . DS . "include" . DS . "setup.php");
require_once(JPATH_BASE . DS . "include" . DS . "functions.php");

$to ='';
$serialno= $_GET['cns'];
$frm = $_GET['cnfrom'];
$to = $_GET['cnto'];
$j=0;
if($to!=''){
for ($i = $frm; $i <= $to; $i++) {
    $sql = "SELECT count(*) as tot FROM `inventories` where cn_no='$serialno$i'";
    $r = mysql_fetch_array(mysql_query($sql));
    if($r['tot']>0){
        echo '<li>'.$serialno . $i .' already exists! </li>';
        $j++;
    }
}
}else{
    $sql = "SELECT count(*) as tot FROM `inventories` where cn_no='$serialno$frm'";
    $r = mysql_fetch_array(mysql_query($sql));
    if($r['tot']>0){
        echo '<li>'.$serialno . $frm .' already exists! </li>';
        $j++;
    }
}


if($j==0)
    echo 'Success';